package com.ming.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;

/**
 * @Auther: tangC
 * @Date: 2020/7/9 16:50
 * @Description:
 */
@Configuration
public class RedisListener {

    @Autowired
    ConfigReflushListener configReflushListener;

    @Autowired
    RedisMessageListenerContainer redisMessageListenerContainer;

    @Bean
    public MessageListenerAdapter listenerAdapter(){
        MessageListenerAdapter listenerAdapter = new MessageListenerAdapter(configReflushListener, "reflush");
        redisMessageListenerContainer.addMessageListener(
                listenerAdapter
                ,new PatternTopic("reflush"));
        return listenerAdapter;
    }
}
